package com.hlx.utils;

import lombok.Data;

import java.text.DecimalFormat;
import java.time.LocalTime;

@Data
public class TimeUtils {
    public LocalTime calculateTime(Integer distance,Integer velocity,LocalTime startTime){
        Float totalF = (float)distance / (velocity-50);
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        String formattedResult = decimalFormat.format(totalF);
        Float minuteF = Float.parseFloat(formattedResult) * 60;
        Integer minuteI = Math.round(minuteF);
        Integer min = minuteI % 60;
        Integer hour = minuteI / 60;
        System.out.println("min"+min+" "+"hour"+hour);
        if(min+startTime.getMinute() >= 60){
            hour+=1;
            min = (min+startTime.getMinute())-60;
        }
//        LocalTime startTime = trainNumber.getStartTime();
//        LocalTime endTime = LocalTime.of(startTime.getHour()+hour,startTime.getMinute()+min,0);
        return LocalTime.of(startTime.getHour()+hour,min,0);
    }
}
